package com.practice.controller.admin;

import com.practice.common.result.Result;
import com.practice.pojo.admin.dto.PageArticleDTO;
import com.practice.pojo.user.entity.Article;
import com.practice.service.admin.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/ydd_article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;
    /**
     * 文章列表-分页
     * @return
     */
    @GetMapping("/list")
    public Result list(PageArticleDTO dto){
        return articleService.list(dto);
    }

    /**
     * 文章删除
     * @return
     */
    @GetMapping("/del")
    public Result del(Long id){
        return articleService.deleteById(id);
    }

    /**
     * 文章添加
     * @return
     */
    @PostMapping("/add")
    public Result add(@RequestBody Article article){

        return articleService.add(article);
    }

    /**
     * 文章详情
     * @return
     */
    @GetMapping("/rowInfo")
    public Result rowInfo(Integer id){

        return articleService.selectById(id);
    }

    /**
     * 文章修改
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody Article article){
        return articleService.update(article);
    }

}
